package Text34;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    //    第一行包含 2个整数 n和 K。
//    第二行包含 n个整数 A1,A2,···,An。
    //(Aj * 10 ^ len(Ai)) %k == -Ai % k
//t = (k - (Ai % k)) % k
    static int N = 100010;
    static int[] a = new int[N];
    static int[][] s = new int[11][N];

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] s1 = in.readLine().split(" ");
        int n = Integer.parseInt(s1[0]);
        int k = Integer.parseInt(s1[1]);
        String[] s2 = in.readLine().split(" ");
        //1.输入数据+2.预处理s数组
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(s2[i]);;
            int t = a[i] % k;
            for (int j = 0; j < 11; j++) {
                s[j][t]++;
                t = t * 10 % k;
            }
        }
        //3.循环数组计算答案
        long res = 0;
        for (int i = 0; i < n; i++) {
            int t = a[i] % k;
            int len = String.valueOf(a[i]).length();
            res += s[len][(k - t) % k];
            int r = t;
            while (len-- > 0) {
                r = r * 10 % k;
            }
            if(r==(k - t) % k){
                res--;
            }
        }
        System.out.println(res);
    }
}
